 $(".limitnum-direct>textarea")[0].addEventListener("input",function(){//字数监听
       var text=$(this).val();
       var length=text.length;
       $(".limitnum-direct>span>i").html(length);
  })
  $(".limitnum>textarea")[0].addEventListener("input",function(){//字数监听
       var text=$(this).val();
       var length=text.length;
       $(".limitnum>span>i").html(length);
  })
new Upload({//logo上传
   elem: '.add-file-btn',
   url: '/Api/Upload/ajax_upload_file',
   name: 'Filedata',
   formId: 'upload-form',
   inputId: 'file-upload-input',
   success: function(json) {
     if (json.code == 1) {
       this.btn.parent().find(".list").remove();
       var txt='<div class="list">'+
                   '<img src="'+json.url+'" alt="">'+
                   '<div class="operate">'+
                     '<i class="iconfont preview-img" style="left:33px;">&#xe615;</i>'+
                   '</div>'+
                   '<div class="musk"></div>'+
                   '<input type="hidden" name="logo" value="'+json.url+'">'+
                 '</div>';
       this.btn.before(txt);
       $.alert('上传成功');
        this.btn.text("修改");
       this.btn.css({fontSize:"15px"});
     }
   },
   error: function() {
     $.alert('上传失败');
   }
 });

 //添加机构成员表单验证
var memberModalForm = $('#memberModal-form');
memberModalForm.validate();
memberModalForm.on('submit',function(){
if (memberModalForm.valid()) {
    if ($('.addmemberurl>.list>img').length <= 0){
          $.alert('请上传照片!');
          return false;
      }
    else{
      var name=$(".memberName").val();
      var intr=$(".memberIntr").val();
      var url=$(".addmemberurl>.list>img").attr("src");
      var position=$(".memberPosition").val()
      var number= $(".memberlist>tr").length+1;
   $(".memberlist").append("<tr><td>"+number+"</td><td><img src='"+url+"' alt='' style='width:100px;height:100px' /></td><td>"+name+"</td><td>"+position+"</td><td>"+intr+"</td><td class='mr'><a class='iconright editmember blue-color' href='javascript:;'data-target='#editmemberModal' data-toggle='modal' ><i class='iconfont'>&#xe605;</i>编辑</a><a class='iconright blue-color delete' href='javascript:;' style='color:#f58381;''><i class='iconfont' >&#xe65f;</i>删除</a></td></tr>")
      $("#memberModal").addClass("hide")  
    return false;
    }

    }
})
//编辑机构成员
var tds={}
$("body").on("click",".editmember",function(e){
  var  e=event.target;
  if(e.tagName=="I"){
  tds=$(e).parent("a").parent("td").siblings();
 }
 else{
  tds=$(e).parent("td").siblings();
 } 
  var imgurl=$(tds[1]).find("img").attr("src")
  var editname=$(tds[2]).text()
  var editposition=$(tds[3]).text()
  var editmemberIntr=$(tds[4]).text()
  $(".editmemberName").val(editname)
  $(".editmemberPosition").val(editposition)
  $(".editmemberIntr ").val(editmemberIntr)
  $(".editaddmemberurl>.list>img").attr("src",imgurl)
})
  $(".editmemberbtn").click(function(){
    var editmemberForm = $('#editmemberModal-form');
    editmemberForm.validate();
    if(editmemberForm.valid()){
          var name=$(".editmemberName").val()
          var position=$(".editmemberPosition").val()
          var  editmemberIntr=$(".editmemberIntr ").val()
          var url=$(".editaddmemberurl>.list>img").attr("src")
          $(tds[2]).text(name)
          $(tds[3]).text(position)
          $(tds[4]).text(editmemberIntr)
          $(tds[1]).find("img").attr("src",url)
          $("#editmemberModal").addClass("hide")    
         
    }
    return false;   
  })
//添加案例
var caseModalForm = $('#caseModal-form');
caseModalForm.validate();
caseModalForm.on('submit',function(){
if (caseModalForm.valid()) {
    if ($('.addcaseurl>.list>img').length <= 0){
          $.alert('请上传照片!');
          return false;
      }
    else{
      var name=$(".caseName").val();
      var intr=$(".caseIntr").val();
      var url=$(".addcaseurl>.list>img").attr("src");
      var number= $(".memberlist>tr").length+1;
   $(".caselist").append("<tr><td>"+number+"</td><td><img src='"+url+"' alt='' style='width:100px;height:100px' /></td><td>"+name+"</td><td>"+position+"</td><td>"+intr+"</td><td class='mr'><a class='iconright editmember blue-color' href='javascript:;'data-target='#editmemberModal' data-toggle='modal' ><i class='iconfont'>&#xe605;</i>编辑</a><a class='iconright blue-color delete' href='javascript:;' style='color:#f58381;''><i class='iconfont' >&#xe65f;</i>删除</a></td></tr>")
      $("#memberModal").addClass("hide")  
    return false;
    }

    }
})